import {  Menu, Affix  } from'antd';
import { Link } from 'react-router-dom';

interface Iprops {
    OnClickRecommend: ()=>void,
    OnClickHome: ()=>void,
}

export default function TopMenu(props: Iprops){

    // 调用回到主页所定义方法，根据所选项改变渲染
    const ClickRecommend = (e:any)=>{
        // console.log("点击的key：", e.key);
        props.OnClickRecommend();
    }
    // 调用推荐所定义方法，根据所选项改变渲染
    const ClickHome = (e:any)=>{
        // console.log("点击的key：", e.key);
        props.OnClickHome();
    }

    return (
        <div>
            <Affix offsetTop={0}>
                <Menu mode="horizontal">
                    <Link to="/home">
                    <Menu.Item key="主页" onClick={ClickHome} >主页</Menu.Item>
                    </Link>
                    <Link to="/recommend">
                    <Menu.Item key="为你推荐" onClick={ClickRecommend} >推荐</Menu.Item>
                    </Link>
                </Menu>
            </Affix>
        </div>
    );

}